package com.rykj.energy.common.enums;

public enum TaskState {
    //设备品牌
    run("运行中","run"),
    wait("等待中","wait"),
    close("关闭/删除","close");


    private String name;
    private String code;

    TaskState(String name, String code){
        this.name = name;
        this.code = code;
    }
    public static String getCodeByName(String name){
        if(null==parseByName(name)){
          return "";
        }
        return parseByName(name).getCode();
    }

    public static String getNameByCode(String code){
        if(null==parseByCode(code)){
            return "";
        }
        return parseByCode(code).getName();
    }

    public static TaskState parseByName(String name){
        for(TaskState type : values()){
            if(type.getName().equals(name)){
                return type;
            }
        }
        return null;
    }

    public static TaskState parseByCode(String code){
        for(TaskState type : values()){
            if(type.getCode().equals(code)){
                return type;
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public String getCode() {
        return code;
    }

    }
